/* -*-mode:java; c-basic-offset:2; -*- */
package example;

import java.io.*;
import com.jcraft.jzlib.*;

public class test_stream_deflate_inflate {
	public static void main(String[] args) {
		try {
			FileInputStream fis = new FileInputStream("D:/eclipseNew/WorkSpace/Titled/examples/test.wlk");
			FileOutputStream fos = new FileOutputStream("test.wlk.gzip");
			ByteArrayOutputStream out = new ByteArrayOutputStream();
			ZOutputStream zOut = new ZOutputStream(fos,
					JZlib.Z_BEST_COMPRESSION);
			ObjectOutputStream objOut = new ObjectOutputStream(zOut);
			//String hello = "Hello World!";
			int len = fis.available();
			byte[] b =new byte[len];
			fis.read(b);
			objOut.writeObject(b);
			zOut.close();
			fos.close();
			fis.close();
			
			fis = new FileInputStream("test.wlk.gzip");
			fos = new FileOutputStream("newtest.wlk");
			//ByteArrayInputStream in = new ByteArrayInputStream(out
			//		.toByteArray());
			ZInputStream zIn = new ZInputStream(fis);
			ObjectInputStream objIn = new ObjectInputStream(zIn);
			//len = objIn.available();
			//System.out.println("len="+len);
			//b =new byte[len];
			//objIn.read(b);
			fos.write((byte[])objIn.readObject());
			fos.close();
			fis.close();
			//System.out.println(objIn.readObject());
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}
}
